package com.typhoon.dubbo_provider.dao;

import java.util.List;

import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import com.typhoon.entity.User;
import com.typhoon.util.DataSourceUtils;

@Repository("userDao")
public class UserDao {

    JdbcTemplate jdbcTemplate = DataSourceUtils.getJdbcTemplate();

    public User queryByPK(Long id) {
        String sql = "		select * from user where id = ? limit 1 	";
        List<User> list = this.jdbcTemplate.query(sql, BeanPropertyRowMapper.newInstance(User.class), id);
        if(null == list || list.isEmpty()) {
            return null;
        }
        return list.get(0);
    }

}